﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Forms;

namespace KitBuilder.Views
{
    /// <summary>
    /// Interaction logic for ImportWindow.xaml
    /// </summary>
    public partial class ImportWindow : Window
    {
        private int pageNumber;
        private string cardfileName;
        ImportMatches importPanel = null;

        public ImportWindow(string cardfileName)
        {
            InitializeComponent();

            pageNumber = 1;
            this.cardfileName = cardfileName;
        }

        private void FileUpload_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileUploadDialog = new OpenFileDialog();
            fileUploadDialog.Multiselect = false;
            fileUploadDialog.Filter = "AllFiles|*.*";

            fileUploadDialog.ShowDialog();


        }

        private void ImportWizard_Next_Click(object sender, RoutedEventArgs e)
        {
    
            // Move to the next page: 1: file selector, 2: matches, 3:load data
            if (pageNumber < 3)
            {
                pageNumber++;
            }
            else
            {
                pageNumber = 3;
            }

            if (pageNumber == 2){
                ImportWizardMatches_Panel.Children.Clear();
                importPanel = new ImportMatches(cardfileName);
                ImportWizardMatches_Panel.Children.Add(importPanel);
            }

            if (pageNumber == 3)
            {
                ImportWizardMatches_Panel.Children.Clear();
                ImportPersistence importPersistence = new ImportPersistence(cardfileName, importPanel.GetItemMatches());
                ImportWizardMatches_Panel.Children.Add(importPersistence);
            }
            
        }

        private void ImportWizard_Back_Click(object sender, RoutedEventArgs e)
        {
            pageNumber--;
        }
    }
}
